package com.ktjiaoyu.crm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjiaoyu.crm.mapper.UserMapper;
import com.ktjiaoyu.crm.pojo.User;
import com.ktjiaoyu.crm.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public User login(String usrName, String usrPassword) {
        return userMapper.selectUserByNameAndPwd(usrName, usrPassword);
    }

    @Override
    public User getUserById(Integer usrId) {
        return userMapper.selectById(usrId);
    }

    @Override
    public List<User> findAllUsers() {
        return userMapper.selectList(new QueryWrapper<User>());
    }

    @Override
    public int saveUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int deleteUser(int id) {
        return userMapper.deleteById(id);
    }

    @Override
    public List<User> selectUsersPage(Integer roleId, String usrName, int i, Integer userPageSize) {
        return userMapper.selectUsersPage(roleId, usrName, i, userPageSize);
    }

    @Override
    public User getUser(Long usrId) {
        return userMapper.selectById(usrId);
    }

}
